export default {
	namespaced: true,
	state: () => ({
		address: JSON.parse(uni.getStorageSync('address') || '{}'),
		userInfo:JSON.parse(uni.getStorageSync('userInfo') || '{}'),
		token: uni.getStorageSync('token'),
		// 跳转回页面到路径
		redirectInfo:{}
		
	}),
	mutations: {
		// 设置重定向参数
		updateRedirectInfo(state,obj){
			state.redirectInfo = obj
			console.log(state.redirectInfo)
		},
		// 保存token
		updateToken(state,token){
			state.token=token
			uni.setStorageSync('token',token)
		},
		// 保存用户信息
		updateUserInfo(state,userInfo){
			state.userInfo=userInfo
			uni.setStorageSync('userInfo',JSON.stringify(userInfo))
		},
		// 保存收货地址
		updateAddress(state,address){
			state.address=address
			uni.setStorageSync('address',JSON.stringify(address))
		}
	},
	getters: {
		addstr(state) {
			return `${state.address.provinceName}${state.address.cityName}${state.address.countyName}${state.address.detailInfo}`
		}
	}
}
